<template>
  <div class></div>
</template>
<script>
import axios from "@/utils/requestdp";
import dayjs from "dayjs";

export default {
  name: "APIqueryDbzonghaoreliangnumzz",
  components: {},
  data() {
    return {};
  },
  computed: {
    ishistory: function () {
      return this.$store.state.daping.ishistorytime;
    },
    timerangarr: function () {
      return this.$store.state.daping.timepick;
    },
  },
  watch: {
    "$store.state.daping.bigScreen": {
      handler: function (n, o) {
        this.loadData(n)
      },
    },
  },
  mounted() {
    this.watchEvent();
  },
  methods: {
    watchEvent() {
      //先清除定时任务
      if (
        this.$store.state.daping.intervalArr["APIqueryDbzonghaoreliangnumzz"] !=
        undefined
      ) {
        return;
      }

      this.loadData();
      let interval = setInterval(() => {
        this.loadData();
      }, this.$root.setting.data.interval);
      this.$store.state.daping.intervalArr["APIqueryDbzonghaoreliangnumzz"] = [
        { interval: interval },
      ];
    },
    loadData() {
      let day = dayjs().format("YYYY-MM-DD");
      axios.get(`/report/networkChangeCost?date=${day}`).then(res => {
        let rs = res.data.table2;
        let heji = 0;
        rs.forEach(v => {
          if (v.pid == '0') {
            heji += v.running_heat
          }
        })
        this.$store.state.daping.zonghaoreliangzz = Math.round(heji)
      })
    },
  },
};
</script>
<style lang='scss' scoped>
</style>